package com.stockz.downloaderx.util;

import java.io.File;
import java.util.Date;

import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;

import com.stockz.core.util.Config;
import com.stockz.core.util.CoreConstant;
import com.stockz.core.util.CoreUtil;

@Component
@SuppressWarnings("deprecation")
public class DownloaderUtil {
	
	public static String getDownloadDirectoryPath(Date date, String exchangeCode){
		if(date != null && StringUtils.hasText(exchangeCode)){
			return CoreUtil.getFilebasePath()+
					File.separator+exchangeCode+
					File.separator+(date.getYear()+1900)+
					File.separator+(date.getMonth()+1);
		}
		return null;
	}
	
	public static String getDownloadFilePath(Date date, String exchangeCode){
		if(date != null && StringUtils.hasText(exchangeCode)){
			return getDownloadDirectoryPath(date, exchangeCode)+File.separator+date.getDate()+
					Config.get(CoreConstant.keyExtentionFilebaseFile);
		}
		return null;
	}
}
